<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="java.util.Calendar" %>
<% String title = "信息综合系统"; %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<title><%=title %>-中标库管理</title>
<head>

<script src="${pageContext.request.contextPath}/javascript/httpService.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="apple-itunes-app" content="app-id=429849944"/>
<meta name="apple-touch-fullscreen" content="no"/>
<meta content="telephone=no" name="format-detection"/>
<meta name="apple-mobile-web-app-capable" content="no"/>
</head>

<!-- BEGIN BODY -->
<body class="fixed-top" >

<jsp:include page="/common/headerPage.jsp"></jsp:include>
<!-- BEGIN CONTAINER 容器 -->
<div id="container" class="row-fluid">
    <!-- BEGIN SIDEBAR 侧边栏-->
    <jsp:include page="/common/left.jsp"></jsp:include>
    <!-- END SIDEBAR -->

    <!-- BEGIN PAGE -->
    <div id="main-content">
        <!-- BEGIN PAGE CONTAINER-->
        <div class="container-fluid">
            <!-- BEGIN PAGE HEADER-->
            <div class="row-fluid">
                <div class="span12">
                    <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                    <h3 class="page-title">中标库管理</h3>
                    <ul class="breadcrumb" style="padding-bottom : 12px;">
                        <li><a href="${pageContext.request.contextPath}/user/index.do">首页</a>
                            <span class="divider">/</span></li>
                        <li class="active">中标库管理</li>
                        <li class="pull-right search-wrap">
                            <input type="button" class="btn  btn-info" onclick="toggleCondi();" id="show"
                                   value="隐藏筛选区域"/>
                             &nbsp;&nbsp;
                             <div class="btn-group pull-right">
			                    <button class="btn dropdown-toggle" data-toggle="dropdown">更多 <i class="icon-angle-down"></i>
			                    </button>
			                    <ul class="dropdown-menu pull-right">
			                        <li><a href="${pageContext.request.contextPath}/bid/download.do">下载已筛选中标库记录</a></li>
			                        <li><a href="#" onclick="openUpload('中标库');">Excel批量上传N条</a></li>
			                        <li><a href="#" onclick="showOpen(0,'新增中标库');">页面新增一条</a></li>
			                    </ul>
			                </div>     
                        </li>
                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
            <!-- END PAGE HEADER-->
            <!-- BEGIN BASIC PORTLET-->
            <div class="widget">
                <div class="row-fluid">
                    <div class="clearfix" >
                    <form>
                    <input type="text" class="span2" id="bidId" placeholder="请填写ID" data-provide="typeahead"
                               data-items="4"/>
                    <input type="text" class="span3 typeahead" id="terminal" placeholder="请填写入货乙方" data-provide="typeahead" data-items="4" />

					</br><select id="province" multiple="multiple" size="1" class="input-medium m-wrap">
                         <option value="-1" disabled>请选择省份</option>
                         <c:forEach items="${provinces}" var="shenfen" varStatus="status">
                             <option value="${shenfen}">${shenfen}</option>
                         </c:forEach>
                    </select>
                    
                    <select id = "city" multiple="multiple" size="1" class="input-medium m-wrap">
	                         <option value="-1" disabled >请选择地市</option>
	                         <c:forEach items="${citys}" var="city" varStatus="status">
	                             <option value = "${city}" >${city}</option>
	                         </c:forEach>
                    </select>
                        
                    <select id = "product" multiple = "multiple" size="1" class="input-medium m-wrap">
                         <option value="-1" disabled >请选择品种</option>
                         <option value = "A" >A</option>
                         <option value = "Y" >Y</option>
                         <option value = "Z" >Z</option>
                         <option value = "B" >B</option>
                     </select>

					 <select id = "pack" multiple = "multiple" size="1" class="input-medium m-wrap">
                         <option value="-1" disabled >请选择包装</option>
                         <option value = "12" >12</option>
                         <option value = "24" >24</option>
                         <option value = "36" >36</option>
                         <option value = "48" >48</option>
                         <option value = "20" >20</option>
                         <option value = "40" >40</option>
                         <option value = "30" >30</option>
                         <option value = "60" >60</option>
                         <option value = "5" >5</option>
                         <option value = "10" >10</option>
                         <option value = "240" >240</option>
                         <option value = "480" >480</option>
                     </select>
                    <input type="button" id="seach" name="seach" value="查询" class="btn  btn-primary"
                               style="margin-bottom: 10px;"
                               onclick="ajaxGetBid(1,8);">
                    <input type="reset" id="reset" name="reset" value="重置该页面" class="btn  btn-primary"
              			style="margin-bottom: 10px;" onclick="resetf();"/>
                    </form>
                    </div>
                </div>
                <div id="updateBidForm" hidden>
                    <div class="modal-body" style="height: 90%">
                     <form action="${pageContext.request.contextPath }/bid/addBid.do" method="post" id="bidForm">
                        <input id="bidIdU" value="" hidden = "hidden" name="id">
                        <span style="color:red;">*</span>&nbsp;请填写开始时间:
                        <input type="text" id="startDateU" value='' class="Wdate noNull" name ="stime" style="width: 120px;"
                               onfocus="WdatePicker({dateFmt:'yyyy/MM/dd',maxDate:'#F{$dp.$D(\'endDateU\')}',lang:'zh-cn',readOnly:true})"
                               />
                               <span style="color:red;">*</span>&nbsp;请填写结束时间:
                        <input type="text" id="endDateU" value='' class="Wdate noNull" name="etime"style="width: 120px;"
                               onfocus="WdatePicker({dateFmt:'yyyy/MM/dd',minDate:'#F{$dp.$D(\'startDateU\')}',lang:'zh-cn',readOnly:true})"
                               />
                               </br>请填写入货乙方:
                        <input type="text" class="span3" id="terminalU" name="terminal" />
<span style="color:red;">*</span>&nbsp;请填写中标价：
                        <input type="text" class="span2 noNull" id="zbjU" name="zbj"
                        onblur="if(!/^[0-9]+([.]{1}[0-9]+){0,1}$/.test(this.value)){layer.msg('只能输入【数字】');this.value='';}"
                        />
                              </br>请选择地市:
 						<select id = "cityU" name="city"  size="1" class="input-medium m-wrap">
	                         <c:forEach items="${citys}" var="citys" varStatus="status">
	                             <option value = "${citys}" >${citys}</option>
	                         </c:forEach>
                     	</select>
                   
                       <span style="color:red;">*</span>&nbsp;请选择省份：
                        <select id="provinceU" size="1" name="province" class="input-medium m-wrap">
	                         <c:forEach items="${provinces}" var="shenfen" varStatus="status">
	                             <option value="${shenfen}">${shenfen}</option>
	                         </c:forEach>
	                    </select>
                        </br><span style="color:red;">*</span>&nbsp;请选择品种：
	                    <select id = "productU" size="1" name="product" class="input-medium m-wrap">
	                         <option value = "A" >A</option>
	                         <option value = "Y" >Y</option>
	                         <option value = "Z" >Z</option>
	                         <option value = "B" >B</option>
	                     </select>
<span style="color:red;">*</span>&nbsp;请选择包装：
					 <select id = "packU" size="1" name="pack" class="input-medium m-wrap">
                         <option value = "12" >12</option>
                         <option value = "24" >24</option>
                         <option value = "36" >36</option>
                         <option value = "48" >48</option>
                         <option value = "20" >20</option>
                         <option value = "40" >40</option>
                         <option value = "30" >30</option>
                         <option value = "60" >60</option>
                         <option value = "5" >5</option>
                         <option value = "10" >10</option>
                         <option value = "240" >240</option>
                         <option value = "480" >480</option>
                     </select>
                     </form>
                    </div>
                </div>
<div id="uploadFileForm" hidden>
	<div class="modal-body">
		<form
			action="${pageContext.request.contextPath}/bid/upload.do?i=<%=Math.random() %>"
			method="post" id="uploadForm" enctype="multipart/form-data">
			点击该按钮选择文件:<input type="file" name="excelFile"
				multiple="multiple" class="input-medium" id="file"><br/>

		</form>
	</div>
</div>

<div id="errorInfoDiv" hidden="hidden">
	<table class="table table-striped table-hover table-bordered" style="font-size:11px;color:red;width:750px;margin:12px;">
		<thead>
			<tr>
				<td>出错行号</td>
				<td>出错标题</td>
				<td>标准字段</td>
				<td>错误字段</td>
			</tr>
		</thead>
		<tbody id="error-body"></tbody>
	</table>
</div>


				<div class="row-fluid">
                	<div class="span12">
                    <!-- BEGIN ALERTS PORTLET-->
                    <div class="widget blue">
                        <div class="widget-title">
                            <h4><i class="icon-reorder"></i>
                                <a href="javascript:;" id="getProp" style ="color:white;">复制</a>
                            </h4>
                            <span class="tools">
								<a href="javascript:;" class="icon-chevron-down"></a>
							</span>
                        </div>
				    
                        <div class="widget-body" style="overflow:auto">
	                        <div class="pageBottom" style="text-align:center;">
	                            <input type="hidden" id="page-size" value="0"/>
	                            <div id="callBackPager" class="paging_bootstrap pagination"></div> 
	                        </div>
                        	<table class="table table-striped table-hover table-bordered" width="640px;"
                           		style="table-layout:fixed">
                                <thead>
                                 <tr>
		                            <th style="width:15px;"><input type="checkbox" name="choiceAll" value="all" id ="allAndNotAll"/></th>
                                    <th width="70px">id</th>
		                            <th width="70px">省份</th>
									<th width="70px">地市</th>
									<th width="70px">品种</th>
									<th width="70px">包装</th>
									<th width="200px">入货乙方</th>
									<th width="70px">开始时间</th>
									<th width="70px">结束时间</th>
									<th width="70px">中标价  </th>
		                        </tr>
                                </thead>
                                <tbody id="distribute-body">
                        		</tbody>
                            </table>
                        </div>

                    </div>
                    <!-- END ALERTS PORTLET-->
                	</div>
            	</div>
               
            </div>
            <!-- END BASIC PORTLET-->
        </div>
    </div>
</div>
</div>

<!-- BEGIN FOOTER -->
<jsp:include page="/common/footer.jsp"></jsp:include>
<!-- END FOOTER -->

<!-- BEGIN JAVASCRIPTS -->
<!-- Load javascripts at bottom, this will reduce page load time -->
<%--<script src="js/jquery-1.8.3.min.js"></script>--%>
<script src="${pageContext.request.contextPath}/js/jquery-1.7.1.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.nicescroll.js" type="text/javascript"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-ui-1.9.2.custom.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.slimscroll.min.js"></script>
<script src="${pageContext.request.contextPath}/js/fullcalendar.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.easy-pie-chart.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.sparkline.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/Chart.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.scrollTo.min.js"></script>
<!--common script for all pages-->
<script src="${pageContext.request.contextPath}/js/common-scripts.js"></script>

<script type="text/javascript" src="${pageContext.request.contextPath}/js/layer/layer.js"></script>
<%--<script src = "${pageContext.request.contextPath}/js/jquery.min.js" > </script>--%>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap-multiselect.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap-multiselect.css" type="text/css"/>

<script src="${pageContext.request.contextPath}/js/bootstrap-typeahead.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/extendPagination.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="http://img3.job1001.com/js/ZeroClipboard/jquery.zclip.min.js"></script>

<!-- END JAVASCRIPTS -->
<!-- 自定义的script方法 -->
<script type="text/javascript">
    $(document).ready(function () {
        $("#show").click(function () {
            $(".clearfix").slideToggle();
        });
        /*通过ID查询*/
        $('#province').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择省份', enableFiltering: true, maxHeight: 300, buttonWidth: '100px'});
        $('#city').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择地市', enableFiltering: true, maxHeight: 300, buttonWidth: '100px'});
        $('#product').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择品种', enableFiltering: true, maxHeight: 300, buttonWidth: '100px'});
        $('#pack').multiselect({includeSelectAllOption:true,nonSelectedText: '请选择包装',enableFiltering: true, maxHeight: 300,buttonWidth: '100px'});
    });
    var terminal = ${condiMap.terminal};
    $('#terminal').typeahead({source: terminal})
    if ( window.clipboardData ) {
        $('#getProp').click(function() {
            var ids = getProp();  
            if(selectedIds.trim().length>0){
       		   ids = selectedIds;
       	    }
            if(ids.trim().length>0){
                window.clipboardData.setData("Text", ids);
                layer.msg("复制成功！"); 
                $("#allAndNotAll").attr("checked", false);  
                $("input[name='choice']:checkbox").each(function(){ 
                    $(this).attr("checked", false);  
              	});
                layer.msg("复制成功！");
            }else{
                layer.alert("您没有选中行！");
            }
        });
    } else {
        $("#getProp").zclip({
            path:'http://img3.job1001.com/js/ZeroClipboard/ZeroClipboard.swf',
            copy:function(){
                   var ids = getProp();  
                   if(selectedIds.trim().length>0){
              		   ids = selectedIds;
              	    }
                   if(ids.trim().length>0){
                       return ids;
                   }else{
                       layer.msg("您没有选中行！");
                   }
                },
            afterCopy:function(){
            	layer.msg("复制成功！"); 
                $("#allAndNotAll").attr("checked", false);  
                $("input[name='choice']:checkbox").each(function(){ 
                    $(this).attr("checked", false);  
              	});
            	layer.msg("复制成功！");
            }
        });
    }
</script>

<script type="text/javascript">
    //隐藏或显示筛选区
    function toggleCondi() {
        var text = $("#show").val();
        if (text == '显示筛选区域') {
            $("#show").val("隐藏筛选区域");
        } else {
            $("#show").val("显示筛选区域");
        }
    }

    //上传文件的大小和格式校验
    function uploadFile() {
        var maxsize = 100 * 1024 * 1024;//100M
        var name = $("#file").val();
        var ext = name.substr(name.lastIndexOf('.') + 1);
        if (ext != 'xls' && ext != 'xlsx') {//文件格式验证
            layer.msg("文件后缀只能为.xls和.xlsx!");
            $("#file").val('');
            layer.closeAll('loading');
            clicked = true;
            return;
        }
        var names = document.getElementById("file");
        var sizes = names.files[0].size;
        if (maxsize < sizes) {  //文件大小验证
            $("#file").val('');
            layer.msg("文件大小不能超过100M!");
            clicked = true;
            return;
        }
        var formData = new FormData($("#uploadForm")[0]);
        layer.msg('拼命执行中，请稍等……', {icon: 16}, function(){
        	layer.closeAll();
        	layer.load(2);
        	$.ajax({
                type: "POST",
                url: $('#uploadForm').attr("action"),
                data: formData,
                cache: false,  
                dataType: "json",
                processData: false,
                contentType : false,
                async:true,
                success: function (result) {
                	var code = result.code;
                	$("#file").val("");
               		if(code==-2){//表示上传的excel格式有错误
               			errorInfo(result.msg);
               			ret = false;
                   	}else if(code==-4){
                        layer.alert("您没有操作权限 ！！！");
                    }else if(code==-3){	//登录用户失效
                   		layer.alert(result.message+'</br>点击前往登录页面:'+'<a href="${pageContext.request.contextPath}/login.jsp">登录页面</a>');
                   		ret = false;
                   	}else if(code==-1){
                   		layer.alert(result.msg);
                   	}else{  //上传成功
                   		layer.closeAll();
                		layer.alert("操作成功！\n"+result.msg);
                		ajaxGetBid(1,8);
                		ret = "success";
                	}
               		return ret;
                },
                error: function (e) {
                	layer.closeAll('loading');
                    layer.msg("操作失败！");
                    return true;
                }
            });
        });
        layer.closeAll('loading');
    }

    //打开上传文件的模式窗口
    function openUploadModal() {
        $('#choosefile').modal();
    }

    //异步请求获取符合筛选条件的流向记录
    function ajaxGetBid(pageNumber, pageSize) {
        //通过ID查询	条线	经理	大区	片区	省份	地市	区县
        var bidId = $("#bidId").val();
       	var product = $("#product").next("div").find("button").attr("title");
        var pack = $("#pack").next("div").find("button").attr("title");
        var province = $("#province").next("div").find("button").attr("title");
        var city = $("#city").next("div").find("button").attr("title");
        var terminal =$("#terminal").val();

        var condiMap = {
        	id:bidId,
       		product: product, pack: pack,
       		province: province, city: city,
       		terminal:terminal,
            pageNumber: pageNumber,
            pageSize: pageSize
        }
        //layer.alert(c1ondiMap);
        layer.load(2);
        $.ajax({
            type: "POST",
            url: "${pageContext.request.contextPath }/bid/selectBidList.do?t=" + Math.random(),
            data: condiMap,
            dataType: "json",
            success: function (result) {
            	$("#distribute-body").html("");
                $(".pageBottom").css('display', 'none');
                if(result!=null){
                	if(result.code==-3){	//登录用户失效
                   		layer.alert(result.message+'</br>点击前往登录页面:'+'<a href="login.jsp">登录页面</a>');
                   	}else if (result.total == 0) {
                        layer.msg("筛选后的记录数为零！")
                    } else {
                        if (result.pageNum == 1) {
                            $('#callBackPager').extendPagination({
                                totalCount: result.total,
                                showPage: 5,
                                pageNum: result.pageNum,
                                limit: result.pageSize,
                                callback: function (curr, limit, totalCount) {
                                    ajaxGetBid(curr, limit);
                                }
                            });
                        }
                        $(".pageBottom").css('display', 'block');
                        createTable(result.pageNum, result.pageSize, result.total, result.list);
                        $("#pageNumber").text(result.pageNum);
                    }
                }else{
                    layer.closeAll('loading');
                    layer.alert("查询结果为null！");
                }
                layer.closeAll('loading');
            },
            error: function (e) {
                layer.closeAll('loading');
                layer.msg("操作失败！");
            }
        });
    };

    //动态创建table
    function createTable(currPage, limit, total, items) {
        var html = [], showNum = limit;
        if (total - (currPage * limit) < 0) showNum = total - ((currPage - 1) * limit);
        for (var i = 0; i < showNum; i++) {
            html.push("<tr ondblclick=\"showOpen('"+items[i].id+"','修改中标库')\" >");
            html.push('<td><input type="checkbox" name="choice" value="'+items[i].id+'"/></td>');
            html.push('<td>' + formatData(items[i].id) + '</td>');
            html.push('<td>' + formatData(items[i].province) + '</td>');
        	html.push('<td>' + formatData(items[i].city) + '</td>');
        	html.push('<td>' + formatData(items[i].product) + '</td>');
        	html.push('<td>' + formatData(items[i].pack) + '</td>');
        	html.push('<td class="Textwrap" title="'+formatData(items[i].terminal)+'" >' + formatData(items[i].terminal) + '</td>');
        	html.push('<td>' + formatData(items[i].stime) + '</td>');
        	html.push('<td>' + formatData(items[i].etime) + '</td>');
        	html.push('<td>' + formatData(items[i].zbj) + '</td>');
            html.push('</tr>');
        }
        var mainObj = $('#distribute-body');
        mainObj.empty();
        mainObj.html(html.join(''));
    };

    //格式化无效数据
    function formatData(data) {
        if (data && data != null) {
            return data;
        } else {
            return "";
        }
    }
    
  //查询按钮绑定回车键
    $("body").keydown(function() {
        if (event.keyCode == "13") {//keyCode=13是回车键
            $('#seach').click();
        }
    });
  
  

</script>
<!-- END BODY -->
<script>
    var htmls = $("#updateBidForm").html();
    var uploadFileHtml = $("#uploadFileForm").html();
    var ret = null;
    function showOpen(id,type) {
        if("修改中标库"==type){
            $.ajax({
                type: "GET",
                async:false,//同步
                url: "${pageContext.request.contextPath }/bid/selectBidByID.do?t=" + Math.random(),
                data: {bidId:id},
                dataType: "json",
                success: function (result) {
                	if(result.code==-3){	//登录用户失效
                   		layer.alert(result.message+'</br>点击前往登录页面:'+'<a href="${pageContext.request.contextPath }/login.jsp">登录页面</a>');
                   	}else { 
                   		ret = result;
                   	}
                },
                error: function (e) {;
                    layer.closeAll('loading')
                    layer.msg("操作失败！");
                }
            });
        }
        
        $("#updateBidForm").remove();
        layer.open({
        	title: [type+'<span style="color:red;font-size:12px;margin-left:10px;">*表示该项必填</span>', 'font-size:18px;'],
            type:1,
            content: htmls, //这里content是一个普通的String
            btn: ['确认', '取消'],
            yes: function(index, layero){
            	layer.load(2);
            	var ret = checkNull();
            	if(ret=="false"){
            		return true;
            	}
            	var action ="";
                if("新增中标库"==type){
                	var action = "${pageContext.request.contextPath }/bid/changeBid.do?flag=N&t=" + Math.random();
                }else if("修改中标库"==type){
                	var action = "${pageContext.request.contextPath }/bid/changeBid.do?flag=E&t=" + Math.random();
                }
                $.ajax({
                    type: "POST",
                    url: action,
                    data: $('#bidForm').serialize(),
                    dataType: "json",
                    success: function (result) {
                    	layer.closeAll('loading');
                    	var code = result.code;
                    	if(code==-3){	//登录用户失效
                       		layer.alert(result.message+'<br/>点击前往登录页面:'+'<a href="${pageContext.request.contextPath}/login.jsp">登录页面</a>');
                       	}else if(code==-4){
                            layer.alert("您没有操作权限 ！！！");
                        }else if(code>0){
                       		layer.closeAll();
                       		layer.msg(result.msg);
	                    	ajaxGetBid(1,8);
	                    }else if(code==-2){ //excel校验不通过
	                    	errorInfo(result.msg);
	                    }else if(code==-1){ // 有错误
	                    	layer.alert(result.msg);
	                    }
                    	layer.closeAll('loading');
                        return false;
                    },
                    error: function (e) {
                    	layer.closeAll('loading');
                        layer.msg("操作失败！");
                        return true;
                    }
                });
                
                return false;
            }
            ,btn2: function(index, layero){
            	layer.closeAll('loading');
            }
            ,cancel: function(){
            	layer.closeAll('loading');
            }
            ,area: ['800px', '500px']
        });
        $("#bidIdU").val(id);  //动态赋值ID
        if(ret!=null&&type=='修改中标库'){
            $("#provinceU").val(ret.province);
            $("#cityU").val(ret.city);
        	$("#productU").val(ret.product);
        	$("#packU").val(ret.pack);
        	$("#terminalU").val(ret.terminal);
        	$("#endDateU").val(ret.etime);
        	$("#startDateU").val(ret.stime);
        	$("#zbjU").val(ret.zbj);
        }
        var terminal = ${condiMap.terminal};
        $('#terminalU').typeahead({source: terminal})
    }

    //非空校验
    function checkNull(type){
    	var noNull = $(".noNull");
    	if(type=='change'){
    		noNull = $("#bidForm").find(".noNull");
    	}
		for(var i=0;i<noNull.length;i++){
			if(noNull[i].value==null||noNull[i].value==undefined||noNull[i].value==""){
				layer.msg("请完善带*号项！");
				return "false";
			}
		}
		return "true";
    }
    
    function errorInfo(items){
   	   var html = [];
   	   for (var i = 0; i < items.length; i++) {
   		   html.push("<tr>");
   		   html.push('<td>' + items[i].err_num.substring(items[i].err_num.indexOf("：")+1)+ '</td>');
              html.push('<td>' + formatData(items[i].err_title) + '</td>');
              html.push('<td style="color:#479DA4;">' + formatData(items[i].err_msg) + '</td>');
              html.push('<td>' + formatData(items[i].err_field) + '</td>');
              html.push('</tr>');
   	   }
   	   var mainObj = $('#error-body');
          mainObj.empty();
          mainObj.html(html.join(''));
          
          var errorInfoHtml = $("#errorInfoDiv").html();
   			layer.open({
   	   	        title: ['错误信息', 'font-size:18px;'],
   	   	        type:1,
   	   	        content: errorInfoHtml //这里content是一个普通的String
   	   	        ,cancel: function(){
   	   	      		layer.closeAll('loading');
   	   	      		openUpload('中标库');
   	   	        	return true;
   	   	        }
   	   	        ,area: ['800px', '400px']
   	   	    });
   		
     		$("#error-info").removeAttr("hidden");
      }
    
  	//重置页面
	function resetf(){
		location.reload();
    }
  	
	//是否已经点击了确定按钮，防止用户重复点击
	var clicked = false;
	//上传
    /*function openUpload() { 
    	clicked = true;
    	$("#uploadFileForm").remove();
        layer.open({
            title: ['请选择目标【中标库Excel】文件', 'font-size:18px;'],
            type:1,
            content: uploadFileHtml, //这里content是一个普通的String
            btn: ['确认', '取消'],
            yes: function(index, layero){
            	if(clicked){
            		clicked = false;
	            	var ret = uploadFile();
	            	if(ret=='success'){
	            		return false;	//关闭框
	            	}
            	}
            }
            ,btn2: function(index, layero){
            	layer.closeAll('loading');
            }
            ,cancel: function(){
            	layer.closeAll('loading');
            }
            ,area: ['400px', '230px']
        });
    }*/
	
    function getProp(){
        obj = document.getElementsByName("choice");
        var check_val = "";
        for(k in obj){
            if(obj[k].checked)
                check_val = check_val+" "+ obj[k].value
        }
        return check_val;
    }
    //所有选中的id
    var selectedIds = "";
    //全选或全不选
    $("#allAndNotAll").click(function() { 
        if (this.checked){  
            $("input[name='choice']:checkbox").each(function(){ 
                  $(this).attr("checked", true);  
            });
            layer.msg('拼命执行中，请稍等……', {icon: 16}, function(){
            	layer.closeAll();
            	layer.load(2);
            	//发送异步请求，获取数据
                sendRequest(pageContextPath + "/bid/selectIds.do", null, function (jsonData) {
                    selectedIds = jsonData.ids;
                    layer.closeAll();
                });
            });
        } else {   
            $("input[name='choice']:checkbox").each(function() {   
                  $(this).attr("checked", false);  
            });
            selectedIds="";
        }  
    });
</script>

<style type="text/css">
	.Textwrap {  
		width: 150px; 
		white-space: nowrap; 
		text-overflow: ellipsis; 
		overflow: hidden; 
	} 
</style>
</body>
</html>